package com.googlecode.stemwijzer.server.modules;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.googlecode.stemwijzer.client.StemwijzerService;
import com.googlecode.stemwijzer.server.DefaultStemwijzerService;
import com.googlecode.stemwijzer.server.session.ServerSession;

/**
 * Provides a class calling a StemwijzerService with an actual instance.
 * 
 * @author roel.hodzelmans
 */
public class StemwijzerProvider implements Provider<StemwijzerService> {

	private final ServerSession session;

	/**
	 * Constructor, taking the ServerSession as argument to have a handle to the service.
	 * 
	 * @param session
	 *            Session
	 */
	@Inject
	public StemwijzerProvider(final ServerSession session) {
		this.session = session;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.google.inject.Provider#get()
	 */
	@Override
	@Singleton
	public StemwijzerService get() {
		return new DefaultStemwijzerService(this.session);
	}
}
